adecc52378499c84963aad260f934ab75715ff9d,android-networking/src/main/java/com/androidnetworking/internal/SynchronousCall.java,SynchronousCall,executeDownloadRequest,#ANRequest#,104
Before Change
okHttpResponse = InternalNetworking.performDownloadRequest(request);
if (okHttpResponse == null) {
ANError anError = new ANError();
anError = request.parseNetworkError(anError);
anError.setErrorDetail(ANConstants.CONNECTION_ERROR);
anError.setErrorCode(0);
return new ANResponse(anError);
}
if (okHttpResponse.code() >= 400) {
ANError anError = new ANError();
anError = request.parseNetworkError(anError);
anError.setErrorCode(okHttpResponse.code());
anError.setErrorDetail(ANConstants.RESPONSE_FROM_SERVER_ERROR);
return new ANResponse(anError);
}
return new ANResponse("success");
} catch (ANError se) {
se.setErrorDetail(ANConstants.CONNECTION_ERROR);
se.setErrorCode(0);
return new ANResponse(se);
} catch (Exception e) {
ANError se = new ANError(e);
se.setErrorDetail(ANConstants.CONNECTION_ERROR);
se.setErrorCode(0);
return new ANResponse(se);
}
}
After Change
}
}
private static <T> ANResponse<T> executeDownloadRequest(ANRequest request) {
Response okHttpResponse;
try {
okHttpResponse = InternalNetworking.performDownloadRequest(request);
if (okHttpResponse == null) {
return new ANResponse<>(Utils.getErrorForConnection(new ANError()));
}
if (okHttpResponse.code() >= 400) {
return new ANResponse<>(Utils.getErrorForServerResponse(new ANError(okHttpResponse),
request, okHttpResponse.code()));
}
return new ANResponse(ANConstants.SUCCESS);
} catch (ANError se) {
return new ANResponse<>(Utils.getErrorForConnection(new ANError(se)));
} catch (Exception e) {
return new ANResponse<>(Utils.getErrorForConnection(new ANError(e)));
}
}